=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 03-12-93 (10:25) Number: 33 From: CALVIN FRENCH Refer#: NONE To: GREG DINERT Recvd: NO Subj: reading/writing from fil Conf: (35) Quick Basi --------------------------------------------------------------------------- On 03-10-93 Greg Dinert wrote to All... GD> Hello, I'm wondering how to read/write from a file. I'm Oh boy, that's a doozy. GD> trying to write the new version of my bbs and I'd like a GD> user list. Here's some RWCS (really well commented source) that should get you on your way... I wrote it just for you -- your priveledged (hehe) '________O_/________________________| SNIP |______________________\_O_______ ' O \ | HERE | / O 'This file created by PostIt! v5.0. '>>> Start of page 1. ' 'RECKEEP.BAS Feel free to use it, abuse it, or whatever you want 'to it... it's yours! ' DEFINT A-Z 'Faster program execution using integers OPEN "USERS.DAT" FOR RANDOM AS #1 LEN = 178 ' ' Ok, Random means that you use a 'record' based system. This makes it ' really quite fast and easy to write to a file, although initially it ' may seem confusing. The 'LEN = 178' is to specify the record LENgth, ' which is 100 (in Bytes). Ok, here goes... (hope it's not too ' confusing) ' ' ' Ok, we need to get the data somehow, but you can change it however ' you like so that it works with your BBS. ' CLS COLOR 11, 0 PRINT "YourBBS Record Entering service: Enter new records " PRINT DO COLOR 15, 0 'Bright White LOCATE 3, 1 LINE INPUT "Users Name? ", USERname$ LINE INPUT "Phone Number? ", UPhoneNum$ LINE INPUT "Address? ", UAddress$ LINE INPUT "Special Information? ", Uinfo$ LINE INPUT "Access Level? ", Ulevel$ LINE INPUT "Alias? ", Uothername$ 'the word 'alias' ' cannot be used LINE INPUT "Password? ", Upassword$ ' as it is ' reserved by QB. COLOR 14, 0 'Yellow PRINT STRING$(80, 205) 'Draws a line. ' ' Ok, this is a little confusing. We need to 'Type' a variable, ' which will be called 'user$', so that we can write this record ' to a file. When you type a variable, you use PUT user$ (or whatever ' you called it) and it will put it to the file, as you will see. ' This way, you can fetch a record as easy as can be, and fairly ' quickly too. The record is actually the data contained in user$, ' and when you GET the record (fetch it), you load the current ' record into the variable (user) specified by GET. The current ' record is specified by the SEEK command, but the current record ' will keep going up one every time you read a record. If you don't ' get all of this, you should look in the manual, and look at other ' people's code as I'm fairly notorius for writing stuff that I ' don't understand, hehe. ' TYPE RecordType 'This is just how I choose to do it. you'll 'understand a little while later. Uname AS STRING * 20 'This sets the length of a persons name 'to 20 bytes, and also specifies that it is 'a string (as in Uname$) PhoneNum AS STRING * 15 Address AS STRING * 40 info AS STRING * 80 Accesslevel AS STRING * 1 ' ' You can just use a number between 1 and 10 to specify access ' (or a letter) and that should give you enough access levels to ' choose from. ' othername AS STRING * 10 ' 'Most people's aliases aren't that long. ' password AS STRING * 12 ' 'Change this however to whatever length you like. ' END TYPE ' 'Now, we'll use DIM to DIM User as RecordType. It's just '>>> Continued on page 2. ... OFFLINE 1.39 * Benji! Watch out for that car! Whap!@#$%^& NO TERRIER --- Maximus 2.01wb * Origin: RJ's Byteline =[HST/DS]= Calgary (403)247-3180 CANADA (1:134/75) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 950 203/23 209/209 280/1 SEEN-BY: 390/1 396/1 15 397/2 2230/100 3603/20